 begintownscript;	

 variables;
int i,j,k,r1,choice;
short weapon;
string dlgstr;
body;
beginstate INIT_STATE;

	set_level(28,18);
	set_name(28,"Tough Mickey");

	if (get_flag(0,3) == 1) {
		force_instant_terrain_redraw();
		set_flag(0,3,2);
		message_dialog("You've made it out of the dungeon, but that is no victory. You are in a fort filled with bandits, you were recently wounded and you haven't found most of your equipment yet. On the other hand the bandits don't know that you are free.","You may be able to find and kill the leader of the bandits before the whole fort realizes that you have escaped.");
}

	add_char_to_group(19,1);
	add_char_to_group(20,1);
	add_char_to_group(21,1);
	add_char_to_group(22,1);
	add_char_to_group(23,1);
	add_char_to_group(24,1);

	if (get_flag(0,0) == 0) {
		force_view_center(36,15);
	force_instant_terrain_redraw();
	message_dialog("... blackness enveloped you.","");
	relocate_character(1,7,20);
	relocate_character(2,7,16);
	relocate_character(3,11,16);
	take_item_char_item(0,0,17,4);
	take_item_char_item(0,2,2,20);
	take_item_char_item(1,1,0,4);
	take_item_char_item(1,0,9,44);
	take_item_char_item(2,1,0,5);
	take_item_char_item(2,0,41,24);
	take_item_char_item(3,0,41,29);
	take_item_char_item(3,1,0,6);
	take_item_char_item(3,2,0,6);
	take_item_char_item(1,2,0,7);
	take_item_char_item(2,2,33,5);

	weapon = 13;
	while (weapon < 40) {
		if (item_type_in_slot(0,weapon) != -1) {
			if ((get_item_variety(item_type_in_slot(0,weapon)) == 1) || (get_item_variety(item_type_in_slot(0,weapon)) == 2) || (get_item_variety(item_type_in_slot(0,weapon)) == 5) || (get_item_variety(item_type_in_slot(0,weapon)) == 6) || (get_item_variety(item_type_in_slot(0,weapon)) == 22) || (get_item_variety(item_type_in_slot(0,weapon)) == 13))
				take_item_char_item(0,weapon,43,17);
}
		if (item_type_in_slot(1,weapon) != -1) {
			if ((get_item_variety(item_type_in_slot(1,weapon)) == 1) || (get_item_variety(item_type_in_slot(1,weapon)) == 2) || (get_item_variety(item_type_in_slot(1,weapon)) == 5) || (get_item_variety(item_type_in_slot(1,weapon)) == 6) || (get_item_variety(item_type_in_slot(1,weapon)) == 22) || (get_item_variety(item_type_in_slot(1,weapon)) == 13))
				take_item_char_item(1,weapon,43,19);
}
		if (item_type_in_slot(2,weapon) != -1) {
			if ((get_item_variety(item_type_in_slot(2,weapon)) == 1) || (get_item_variety(item_type_in_slot(2,weapon)) == 2) || (get_item_variety(item_type_in_slot(2,weapon)) == 5) || (get_item_variety(item_type_in_slot(2,weapon)) == 6) || (get_item_variety(item_type_in_slot(2,weapon)) == 22) || (get_item_variety(item_type_in_slot(2,weapon)) == 13))
				take_item_char_item(2,weapon,41,17);
}
		if (item_type_in_slot(3,weapon) != -1) {
			if ((get_item_variety(item_type_in_slot(3,weapon)) == 1) || (get_item_variety(item_type_in_slot(3,weapon)) == 2) || (get_item_variety(item_type_in_slot(3,weapon)) == 5) || (get_item_variety(item_type_in_slot(3,weapon)) == 6) || (get_item_variety(item_type_in_slot(3,weapon)) == 22) || (get_item_variety(item_type_in_slot(3,weapon)) == 13))
				take_item_char_item(3,weapon,41,19);
}
	if ((weapon == 38) && (get_flag(5,5) < 2)) {
		weapon = 12;
		inc_flag(5,5,1);
}

	weapon = weapon + 1;
}
		set_flag(0,0,1);
}
	 break;	
beginstate START_STATE;
	if ((get_flag(0,5) == 0) && (char_ok(15) == FALSE)) {
		message_dialog("You notice a copper key on the body of the priest. You take it.","");
		set_flag(0,5,1);
		change_spec_item(3,1);
}
break;	

beginstate EXIT_STATE;

break;

beginstate 10;
	if (get_flag(0,1) == 0) {
		force_view_center(35,35);
		force_instant_terrain_redraw();
		set_flag(0,1,1);
		move_to_new_town(1,3,12);
}		
 break;

beginstate 11;
	reset_dialog();
	add_dialog_str(0,"These stairs lead to the top floor of the fort. Are you done exploring the main floor?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"Not yet.");
	choice = run_dialog(1);

	if (choice == 1)
		move_to_new_town(2,6,5);
 break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"The dungeons emit their blackness downstairs. Do you wish to descend?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	choice = run_dialog(1);

	if (choice == 1)
		move_to_new_town(1,14,21);
 break;

beginstate 13;
	if ((get_flag(0,2) == 0) && (party_size() >= 2)) {
		clear_buffer();
		append_string("The blade one of the bandits equips looks an awful lot like the one ");
		append_char_name(1);
		append_string(" used to have.");
		get_buffer_text(dlgstr);
		message_dialog("A priest in red robes stops his chanting as you open the door. It takes him only a second to realize that you are not one of the bandits. He commands the three bandits to slay you and begins to chant a ritual.",dlgstr);
		set_flag(0,2,1);
}
	if ((get_flag(0,2) == 0) && (party_size() == 1)) {
		message_dialog("A priest in red robes stops his chanting as you open the door. It takes him only a second to realize that you are not one of the bandits. He commands the three bandits to slay you and begins to chant a ritual.","");
		set_flag(0,2,1);
}
 break;

beginstate 14;
	if ((get_flag(0,4) == 0) && (party_size() == 4)) {
		clear_buffer();
		append_string("The patrons, though drunk, manage to draw their weapons and attack you. A bandit actually draws ");
		append_char_name(3);
		append_string("'s old weapon.");
		get_buffer_text(dlgstr);
		message_dialog("You've entered the tavern of the fort. You very much doubt that the fort used to have a tavern in its Empire days, but the bandits have turned this small room into a house of boozing.",dlgstr);
		set_flag(0,4,1);
}
	if ((get_flag(0,4) == 0) && (party_size() < 4)) {
		message_dialog("You've entered the tavern of the fort. You very much doubt that the fort used to have a tavern in its Empire days, but the bandits have turned this small room into a house of boozing.","The patrons, though drunk, manage to draw their weapons and attack you.");
		set_flag(0,4,1);
}
 break;

beginstate 15;

	if (get_flag(6,6) == 6) {
	reset_dialog();
	add_dialog_str(0,"You defeated the leader of the bandits and with him gone this group of outlaws will scatter to the four winds. There is nothing left for you to do here. Unless you want to explore some more. Are you ready to leave?",0);
	add_dialog_choice(0,"No, I'm not done yet.");
	add_dialog_choice(1,"Yes, I'm off to other adventures.");
	choice = run_dialog(1);

	if (choice == 1)
		block_entry(1);

	if (choice == 2) {
		message_dialog("You leave the fort and the gruesome memory of the ambush of the platoon. Many good people died to put an end to these bandits. Now their souls may rest in peace.","THE END");
		end_scenario(1);
}
}

	if (get_flag(6,6) == 0) {
	reset_dialog();
	add_dialog_str(0,"You have not yet defeated the bandits. Leaving now would be an act of cowardice, unless you are certain you cannot win. Are you sure you want to leave?",0);
	add_dialog_choice(0,"No, I'm not done yet.");
	add_dialog_choice(1,"Yes, I want to leave this awful palce.");
	choice = run_dialog(1);

	if (choice == 1)
		block_entry(1);

	if (choice == 2) {
		message_dialog("This was supposed to be a simple side tour. You were supposed to fight alongside a platoon of Empire soldiers. This has turned out to be another fine mess. Someone else can clean it since you certainly have no interest in it.","");
		end_scenario(0);
}
}
 break;	